home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
tex
/
dvi
/
dvipssrc.zoo
/
dvips.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-04-22
|
19KB
|
637 lines
/*
* This is the main routine.
*/
#ifndef DEFRES
#define DEFRES (300)
#endif
#include "structures.h" /* The copyright notice there is included too! */
#ifdef VMS
#define GLOBAL globaldef
#include climsgdef
#include ctype
#include descrip
#endif
/*
* First we define some globals.
*/
#ifdef VMS
static char ofnme[252],infnme[252],pap[40],thh[20];
#endif
fontdesctype *fonthead ; /* list of all fonts mentioned so far */
fontdesctype *curfnt ; /* the currently selected font */
sectiontype *sections ; /* sections to process document in */
Boolean manualfeed ; /* manual feed? */
Boolean compressed ; /* compressed? */
Boolean safetyenclose ; /* enclose in save/restore for stupid spoolers? */
Boolean removecomments = 1 ; /* remove comments from included PS? */
Boolean nosmallchars ; /* disable small char optimization for X4045? */
int collatedcopies = 1 ; /* how many collated copies? */
int sectioncopies = 1 ; /* how many times to repeat each section? */
shalfword linepos = 0 ; /* where are we on the line being output? */
integer maxpages ; /* the maximum number of pages */
Boolean notfirst, notlast ; /* true if a first page was specified */
Boolean sendcontrolD ; /* should we send a control D at end? */
integer firstpage ; /* the number of the first page if specified */
integer lastpage ;
integer firstseq ;
integer lastseq ;
int numcopies ; /* number of copies of each page to print */
char *oname ; /* output file name */
char *iname ; /* dvi file name */
char *strings ; /* strings for program */
char *nextstring, *maxstring ; /* string pointers */
FILE *dvifile, *bitfile ; /* dvi and output files */
quarterword *curpos ; /* current position in virtual character packet */
quarterword *curlim ; /* final byte in virtual character packet */
fontmaptype *ffont ; /* first font in current frame */
real conv ; /* conversion ratio, pixels per DVI unit */
real vconv ; /* conversion ratio, pixels per DVI unit */
real alpha ; /* conversion ratio, DVI unit per TFM unit */
integer mag ; /* the magnification of this document */
Boolean overridemag ; /* substitute for mag value in DVI file? */
int actualdpi = DEFRES ; /* the actual resolution of the printer */
int vactualdpi = DEFRES ; /* the actual resolution of the printer */
int maxdrift ; /* max pixels away from true rounded position */
int vmaxdrift ; /* max pixels away from true rounded position */
char *paperfmt /* paper format */
#ifdef DEFPFMT
= DEFPFMT ;
#else
;
#endif
int landscape = 0 ; /* landscape mode */
integer fontmem ; /* memory remaining in printer */
integer pagecount ; /* page counter for the sections */
integer pagenum ; /* the page number we currently look at */
long bytesleft ; /* number of bytes left in raster */
quarterword *raster ; /* area for raster manipulations */
integer hh, vv ; /* horizontal and vertical pixel positions */
char *tfmpath = TFMPATH ; /* pointer to directories for tfm files */
char *pkpath = PKPATH ; /* pointer to directories for pk files */
char *vfpath = VFPATH ; /* pointer to directories for vf files */
char *figpath = FIGPATH ; /* pointer to directories for figure files */
char *headerpath = HEADERPATH ; /* pointer to directories for header files */
char *configpath = CONFIGPATH; /* where to find config files */
#ifdef SEARCH_SUBDIRECTORIES
char *fontsubdirpath = FONTSUBDIRPATH ;
#endif
#ifdef FONTLIB
char *flipath = FLIPATH ; /* pointer to directories for fli files */
char *fliname = FLINAME ; /* pointer to names of fli files */
#endif
integer swmem ; /* font memory in the PostScript printer */
int quiet ; /* should we only print errors to stderr? */
int filter ; /* act as filter default output to stdout,
default input to stdin? */
int prettycolumn ; /* the column we are at when running pretty */
int totalpages = 0 ; /* total number of pages */
Boolean reverse ; /* are we going reverse? */
Boolean usesPSfonts ; /* do we use local PostScript fonts? */
Boolean usesspecial ; /* do we use \special? */
Boolean headers_off ; /* do we send headers or not? */
char *headerfile ; /* default header file */
char *warningmsg ; /* a message to write, if set in config file */
Boolean multiplesects ; /* more than one section? */
Boolean disablecomments ; /* should we suppress any EPSF comments? */
char *printer ; /* what printer to send this to? */
char *mfmode ; /* default MF mode */
frametype frames[MAXFRAME] ; /* stack for virtual fonts */
fontdesctype *baseFonts[256] ; /* base fonts for dvi file */
integer pagecost; /* memory used on the page being prescanned */
int delchar; /* characters to delete from prescanned page */
integer fsizetol; /* max dvi units error for psfile font sizes */
Boolean includesfonts; /* are fonts used in included psfiles? */
fontdesctype *fonthd[MAXFONTHD];/* list headers for included fonts of 1 name */
int nextfonthd; /* next unused fonthd[] index */
char xdig[256]; /* table for reading hexadecimal digits */
char banner[] = BANNER ; /* our startup message */
Boolean noenv ; /* ignore PRINTER envir variable? */
extern int dontmakefont ;
#ifdef DEBUG
integer debug_flag = 0;
#endif /* DEBUG */
/*
* This routine calls the following externals:
*/
extern void outbangspecials() ;
extern void prescanpages() ;
extern void initprinter() ;
extern void cleanprinter() ;
extern void dosection() ;
extern void getdefaults() ;
extern void cmdout() ;
extern void numout() ;
extern int add_header() ;
extern char *strcpy() ;
extern void checkenv() ;
extern void getpsinfo() ;
#ifdef FONTLIB
extern void fliload() ;
#endif
/*
* This error routine prints an error message; if the first
* character is !, it aborts the job.
*/
static char *progname ;
void
error(s)
char *s ;
{
extern void exit() ;
(void)fprintf(stderr, "%s: %s\n", progname, s) ;
if (*s=='!') {
if (bitfile != NULL) {
cleanprinter() ;
}
exit(1) ; /* fatal */
}
}
/*
* Initialize sets up all the globals and data structures.
*/
void
initialize()
{
extern char *malloc() ;
int i;
char *s;
nextfonthd = 0;
for (i=0; i<256; i++)
xdig[i] = 0;
i = 0;
for (s="0123456789ABCDEF"; *s!=0; s++)
xdig[*s] = i++;
i = 10;
for (s="abcdef"; *s!=0; s++)
xdig[*s] = i++;
strings = malloc(STRINGSIZE) ;
if (strings == 0)
error("! no memory for strings") ;
maxpages = 100000 ;
numcopies = 1 ;
nextstring = strings ;
iname = strings ;
*nextstring++ = 0 ;
maxstring = strings + STRINGSIZE - 200 ;
bitfile = NULL ;
bytesleft = 0 ;
swmem = SWMEM ;
oname = OUTPATH ;
sendcontrolD = 0 ;
multiplesects = 0 ;
disablecomments = 0 ;
maxdrift = -1 ;
vmaxdrift = -1 ;
}
/*
* This routine copies a string into the string `pool', safely.
*/
char *
newstring(s)
char *s ;
{
int l ;
if (s == NULL)
return(NULL) ;
l = strlen(s) ;
if (nextstring + l >= maxstring)
error("! out of string space") ;
(void)strcpy(nextstring, s) ;
s = nextstring ;
nextstring += l + 1 ;
return(s) ;
}
/*
* Finally, our main routine.
*/
#ifdef VMS
main()
#else
void main(argc, argv)
int argc ;
char *argv[